import React from 'react'
// ===================================================================== Temp
import TableModal from '#cpt/temp/TableModal'
// ===================================================================== global declare
const { $fn } = window
// =====================================================================
// 账单类型
const PayType = [{name:'正常',value:'1'},{name:'冲抵',value:'2'}]
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
	}
	
	model = {}
	
	open = ({ old_spec_code }) => {
		this.modal.open()
		this.query = { spec_code: old_spec_code, show_del:1 }
		// 阻止重复加载数据
		this.fetch()
	}
	
	// paging
	fetch = () => $fn.fetch.call(this, 'bill/speclists')
	
	// 表单
	cols = [
		{ title: '条码号', 			dataIndex: 'old_spec_code', 	...$fn.table.spec_code },
		{ title: '账期', 			dataIndex: 'phase_str', 		width:80 },
		{ title: '账单生成时间', 		dataIndex: 'created_at', 		...$fn.table.time },
		{ title: '账单状态', 		dataIndex: 'status_name', 		width:100 },
		{ title: '账单类型', 		dataIndex: 'pay_type', 			width:80, render: text => $fn.getState(PayType, text) },
		{ title: '备注', 			dataIndex: 'attribute_name', 	width:100 },
		{ title: '医院名称', 		dataIndex: 'hosp_name', 		width:150 },
		{ title: '业务员名称', 		dataIndex: 'salesman_user', 	...$fn.table.name },
		{ title: '接收标本日期', 		dataIndex: 'sp_check_time', 	...$fn.table.time },
		{ title: '自然项目', 		dataIndex: 'parent_kind_name', 	width:220 },
		{ title: '项目名称', 		dataIndex: 'item_name', 		width:220 },
		{ title: '标准价格', 		dataIndex: 'sprice', 			...$fn.table.num },
		{ title: '实际价格', 		dataIndex: 'price', 			...$fn.table.num },
		{ title: '折扣率', 			dataIndex: 'percent', 			...$fn.table.num },
		{ title: '折扣金额', 		dataIndex: 'perprice', 			...$fn.table.num },
	]
	
	render(){
		return TableModal.call(this,{ title: '账单信息', labelWidth:'s7', width:'99%', height:'80%', noSubmit:true })
	}
}

export default Index